package com.gklyj.controller.zhaoping;

import com.gklyj.pojo.Feedback;
import com.gklyj.pojo.User;
import com.gklyj.service.feedbackService;
import com.gklyj.service.userService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@Transactional
public class Zp_feedbackController {

    @Autowired
    feedbackService feedbackService;

    @Autowired
    userService userService;

    /*
    跳转联系反馈页面
     */
    @GetMapping("/toZpFeedbackIndex")
    public String toZpFeedbackIndex(){
        return "zhaoping/zp-feedback";
    }

    /*
    获取某招聘单位的反馈信息
     */
    @GetMapping("/getOneDepartmentFeedback")
    @ResponseBody
    public List<Feedback> getOneDepartmentFeedback(HttpServletRequest request){
        //查询当前登陆人
        Object username = request.getSession().getAttribute("username");
        User user = userService.findUserByUsername(String.valueOf(username));
        return feedbackService.GetOneDepartmentFeedback(user.getName(),user.getU_id());
    }
}
